package com.demo.job.dynamicjob.config;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ScheduledFuture;

@Slf4j
public class ScheduledTask {

    public ScheduledFuture<?> future;

    public ScheduledTask(ScheduledFuture<?> future) {
        this.future = future;
    }

    /**
     * 取消定时任务
     */
    public void cancel() {
        if (future != null) {
            boolean cancel = future.cancel(true);
            log.info("取消定时任务，结果：{}", cancel);
        }
    }
}
